package main

import (
	"OJCenter/client"
	"OJCenter/dao"
	"OJCenter/global"
	"OJCenter/model"
	"OJCenter/provider"
	"OJCenter/router"
	"OJCenter/router/api"
)

func main() {
	global.Init()
	d, err := dao.NewDao()
	if err != nil {
		global.Logger.Errorf("Failed to initialize Dao,err:%v", err)
		return
	}
	cli, err := client.NewClient()
	if err != nil {
		global.Logger.Errorf("Failed to initialize client,err:%v", err)
		return
	}
	//go cli.Ping()
	m, err := model.NewModel(cli, d)
	if err != nil {
		global.Logger.Errorf("Failed to initialize client,error: %v", err)
		return
	}
	a := api.NewApi(m)
	c := router.RouterInit(a)
	provider.Init()
	defer provider.Close()

	c.Run(":8091")

}
